package com.itheima.userdemo.controller;
import com.itheima.userdemo.domain.User;
import com.itheima.userdemo.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
public class UserController {
    @Autowired
    private UserService userService;

    @RequestMapping("/add")
    public String addUser(String username,String password){
        User user =new User();
        user.setPassword(password);
        user.setUsername(username);
        userService.add(user);
        return "success";
    }

    @RequestMapping("/del")
    public String deluUser(Integer id){
        userService.del(id);
        return "success";
    }

    @RequestMapping("/update")
    public String updateUser(Integer id){
        return "success";
    }

    @RequestMapping("/select")
    public List<User> selectAll(){
        return userService.selectAll();
    }
    @RequestMapping("/delay")
    public String delay(){
        return "延迟队列，信息将在20秒后被消费";
    }

}
